﻿using System;

namespace PCSharp
{
    class DemoArray
    {
        public static void InitArray()
        {
            int[] intArray = { 5, 4, 3, 2, 1 };
            int[,] intRegular = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };

            Console.WriteLine("Rank intArray : " + intArray.Rank);
            Console.WriteLine("Rank intRegular : " + intRegular.Rank);

            Array.Sort(intArray);

            foreach (int i in intArray)
                Console.Write(i + ", ");
        }

        public static void RectangularArray()
        {
            int[,] dimension = new int[4, 5];
            int numOne = 0;

            for (int i = 0; i < dimension.GetLength(0); i++)
                for (int j = 0; j < dimension.GetLength(1); j++)
                    dimension[i, j] = numOne++;

            for (int i = 0; i < dimension.GetLength(0); i++)
                for (int j = 0; j < dimension.GetLength(1); j++)
                    Console.Write(dimension[i, j] + " ");
        }

        public static void JaggedArray()
        {
            string[][] companies = new string[3][];

            for (int i = 0; i < companies.Length; i++)
            {
                Console.Write("List of companies : " + (i + 1) + "\t");

                foreach (string s in companies[i])
                    Console.Write("company [i][j]" + s);
            }
        }
    }
}
